package com.test.reference;

import java.lang.ref.WeakReference;

/**
 * 弱引用
 *
 * @author wangjie
 * @version V1.0
 * @date 2020/1/4
 */
public class WeakReferenceDemo {
    public static void main(String[] args) {
        Object obj = new Object();
        WeakReference<Object> weakReference = new WeakReference<>(obj);

        System.out.println(obj);
        System.out.println(weakReference.get());

        obj = null;
        System.gc();

        System.out.println(obj);
        System.out.println(weakReference.get());
    }
}
